package com.user.controller;

import com.user.dao.QueryPageCoupon;
import com.user.dao.coupon.CreateCoupon;
import com.user.dao.coupon.ReceiveCoupon;
import com.user.service.CouponService;
import com.user.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author : Yu
 * @Date 2024/5/19 下午12:34
 */

@RestController
@RequestMapping("/coupon")
public class CouponController {

    @Autowired
    private CouponService couponService;

    @PostMapping("/getCoupon")
    public R getUser(@RequestBody QueryPageCoupon queryPageCoupon) {
        return couponService.getCoupon(queryPageCoupon);
    }

    @PostMapping("/getUserNoCoupon")
    public R getUserNoCoupon(@RequestBody QueryPageCoupon queryPageCoupon) {
        return couponService.getUserNoCoupon(queryPageCoupon);
    }

    @PostMapping("/createCoupon")
    public R createCoupon(@RequestBody CreateCoupon createCoupon) {
        return couponService.createCoupon(createCoupon);
    }

    @GetMapping("/getUser")
    public R getUser(@RequestParam Integer id) {
        return couponService.getUser(id);
    }

    @PostMapping("/receiveCoupon")
    public R receiveCoupon(@RequestBody ReceiveCoupon receiveCoupon) {
        return couponService.receiveCoupon(receiveCoupon);
    }

    @GetMapping("/getMyCoupon")
    public R getMyCoupon(@RequestParam Integer userId) {
        return couponService.getMyCoupon(userId);
    }
}
